home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4369 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: why doesn't atof work properly ?
  5. Date: 3 Feb 1996 17:13 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <3FEB199617132831@erich.triumf.ca>
  9. References: <4f0ivh$3g7e@yuma.ACNS.ColoState.EDU>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4f0ivh$3g7e@yuma.ACNS.ColoState.EDU>, shuyuan xuan <xuan> writes...
  14. >I was reading from da.dat, making everything into a char string. 
  15. >Then I used strtok to interpret the string, converting them into int or 
  16. >double variables through atoi or atof. But atof doesn't seem to work
  17. >at all. Enclosed is the file, da.dat and output.
  18.  
  19. >#include "stdio.h"
  20. >#include "strings.h"
  21. >#include "string.h"
  22.  
  23. You need to #include either (or both, if you wish) math.h or stdlib.h to get
  24. the prototype for atof(). Without it, the compiler will assume atof() returns
  25. an int, with undesireable results.
  26.  
  27.  
  28. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  29. Internet: bennett@triumf.ca         | of one another only when one can be
  30. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  31. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  32. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  33.  
  34.  
  35.